<template>
  <div class="app-container">
    <!-- 列表 -->
    <el-table :data="list" stripe>
      <el-table-column type="index" label="序号" width="60" align="center" />
      <el-table-column prop="lendNo" label="标的编号" width="160" />
      <el-table-column prop="amount" label="标的金额" />
      <el-table-column prop="period" label="投资期数" />
      <el-table-column prop="params.lendYearRate" label="年化利率">
      </el-table-column>
      <el-table-column prop="investAmount" label="已投金额" />
      <el-table-column prop="investNum" label="投资人数" />
      <el-table-column prop="publishDate" label="发布时间" width="150" />
      <el-table-column prop="lendStartDate" label="开始日期" />
      <el-table-column prop="lendEndDate" label="结束日期" />
      <el-table-column prop="params.returnMethod" label="还款方式" />
      <el-table-column prop="params.status" label="状态" />

      <el-table-column label="操作" width="150" align="center">
        <template slot-scope="scope">
          <el-button type="primary" size="mini">
            <router-link :to="'/lend/info/' + scope.row.id"> 查看 </router-link>
          </el-button>
          <el-button
            v-if="scope.row.status == 0"
            type="warning"
            size="mini"
            @click="publish(scope.row.id)"
          >
            发布
          </el-button>
          <el-button
            v-if="scope.row.status == 1"
            type="warning"
            size="mini"
            @click="makeLoan(scope.row.id)"
          >
            放款
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import lendApi from "@/api/lend";
export default {
  data() {
    return {
      list: [],
    };
  },
  created() {
    this.initData();
  },
  methods: {
    publish(id) {
      lendApi.lendPublish(id).then((r) => {
        this.$message.success(r.message);
        this.initData();
      });
    },
    makeLoan(id) {},
    initData() {
      lendApi.list().then((r) => {
        console.log(r.data.items);
        this.list = r.data.items;
      });
    },
  },
};
</script>
